﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ComponentFactory.Krypton.Toolkit;

namespace LED_Utils.MultitrackControl
{
    public partial class FrameEditorForm2 : KryptonForm
    {
        public FrameEditorForm2()
        {
            InitializeComponent();
            kryptonCheckButton1.Checked = true;
        }

        public State _initState;
        public State InitState
        {
            get
            {
                return _initState;
            }
            set
            {
                _initState = value;
                switch (_initState)
                {
                    case State.StartColor:
                        kryptonCheckButton1.Checked = true;
                        break;
                    case State.EndColor:
                        kryptonCheckButton2.Checked = true;
                        break;
                    default:
                        break;
                }
            }
        }

        public enum State
        {
            StartColor,
            EndColor
        }

        private Color _startColor;
        public Color StartColor
        {
            get { return _startColor; }
            set
            {
                _startColor = value;
                kryptonCheckButton1.Color = value;
                _internalChange = true;
                colorWheelPanel1.Color = kryptonCheckButton1.Color;
                _internalChange = false;


            }
        }

        private Color _endColor;
        public Color EndColor
        {
            get { return _endColor; }
            set
            {
                _endColor = value;
                kryptonCheckButton2.Color = value;
                _internalChange = true;
                colorWheelPanel1.Color = kryptonCheckButton2.Color;
                _internalChange = false;

            }
        }

        bool _internalChange;
        private void kryptonCheckButton2_CheckedChanged(object sender, EventArgs e)
        {
            if (_internalChange)
                return;
            _internalChange = true;
            if (kryptonCheckButton2.Checked)
            {
                kryptonCheckButton1.Checked = false;
            }
            colorWheelPanel1.Color = kryptonCheckButton2.Color; 

            _internalChange = false;

        }
        private void kryptonCheckButton1_CheckedChanged(object sender, EventArgs e)
        {
            if (_internalChange)
                return;
            _internalChange = true;
            //kryptonCheckButton2.Checked = !kryptonCheckButton1.Checked;
            if (kryptonCheckButton1.Checked)
            {
                kryptonCheckButton2.Checked = false;
            }
            colorWheelPanel1.Color = kryptonCheckButton1.Color; 

            _internalChange = false;
        }


        private void kryptonButton3_Click(object sender, EventArgs e)
        {
            EndColor = StartColor;
        }

      

        private void cancelButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }

        private void colorWheelPanel1_ColorChanged(object sender, EventArgs e)
        {
            if (_internalChange)
                return;

            if (kryptonCheckButton1.Checked)
            {
                StartColor = colorWheelPanel1.Color;
            }
            else
            {
                EndColor = colorWheelPanel1.Color;
            }
        }

      
    }
}
